<template>
  <scroll-view :scroll-y="true" class="crunchies">
    <cu-custom bgColor="bgco" :isBack="true">
      <block slot="right"> </block>
    </cu-custom>

    <view class="crunchies-top">
      <text>{{ name }}</text>
      <text class="botton-t">{{ summary }}</text>

      <view
        class="listbox"
        v-for="(item, index) in list"
        :key="index"
        @click="jump(item)"
      >
        <image
          src="../../static/img/first.jpg"
          mode="widthFix"
          v-if="index == 0"
        />
        <image
          src="../../static/img/second.jpg"
          mode="widthFix"
          v-else-if="index == 1"
        />
        <image
          src="../../static/img/three.jpg"
          mode="widthFix"
          v-else-if="index == 2"
        />
        <text v-else class="loactionIndex">{{ index + 1 }}</text>

        <image :src="item.cover.fileUrl" class="cash_img" mode="widthFix" />
        <view>
          <text>{{ item.title }}</text>
          <text>{{ item.summary }}</text>
        </view>
      </view>
    </view>
  </scroll-view>
</template>

<script>
import { getSpacialData } from "../../api/api";
export default {
  data() {
    return {
      id: 1,
      list: [],
      name: "",
      summary: "",
    };
  },
  async onLoad({ id }) {
    this.id = id;
    const res = await getSpacialData(this.id);
    if (res[1].data.code == "000000") {
      const { contents, summary, name } = res[1].data.data;
      this.list = contents;
      this.summary = summary;
      this.name = name;
    }
  },
  methods: {
    jump(item) {
      const contype = item.contentSubType;
      let url = "";
      if (contype == 2) {
        url = `/pages/article/article?id=${item.contentId}&token=${
          uni.getStorageInfoSync("userInfo").token
        }`;
      } else if (contype == 3) {
        //图集
        url = "/pages/photo/photo?id=" + item.contentId;
      } else if (contype == 5) {
        //视频
        url = "/pages/video/video?id=" + item.contentId;
      }
      uni.navigateTo({
        url,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.bgco {
  background: linear-gradient(
    90deg,
    rgba(179, 30, 34, 1) 0%,
    rgba(255, 0, 0, 1) 100%
  ) !important;
}
.crunchies /deep/ .cuIcon-back {
  // color: #eee;
  opacity: 0.5;
}
.crunchies {
  width: 750rpx;
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(
    90deg,
    rgba(179, 30, 34, 1) 0%,
    rgba(255, 0, 0, 1) 100%
  );
  .crunchies-top {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 0 32rpx;
    width: 100%;
    > text {
      color: rgba(255, 255, 255, 1);
      line-height: 50rpx;
      font-family: Source Han Sans CN;
      padding-left: 26rpx;
      &:first-child {
        font-size: 48rpx;
        font-weight: 800;
        margin-top: 60rpx;
      }
      &:nth-child(2) {
        font-size: 28rpx;
        font-weight: 400;
        margin-top: 27rpx;
      }
    }
  }
}
.right {
  width: 35rpx;
  height: 35rpx;
}
.listbox {
  width: 685rpx;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 0px 18rpx 0px rgba(255, 107, 134, 1);
  border-radius: 10rpx;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding-left: 37rpx;
  padding-top: 17rpx;
  padding-bottom: 17rpx;
  margin-bottom: 30rpx;
  height: auto;
  > image {
    &:first-child {
      width: 50rpx;
      height: 50rpx;
      background-color: red;
      margin-right: 17rpx;
      flex-shrink: 0;
    }
    &:nth-child(2) {
      width: 203rpx;
      height: 240rpx;
      flex-shrink: 0;
    }
  }
  > view {
    margin-left: 43rpx;
    height: 100%;
    padding-right: 63rpx;
    height: 240rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    > text {
      font-family: Source Han Sans CN;

      &:first-child {
        font-size: 30rpx;
        font-weight: bold;
        color: rgba(36, 36, 36, 1);
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      &:last-child {
        font-size: 24rpx;
        font-weight: 300;
        color: rgba(117, 117, 117, 1);
        margin-top: 43rpx;
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        width: 100%;
        text-align: left;
        -webkit-box-orient: vertical;
      }
    }
  }
}
.botton-t {
  margin-bottom: 74rpx;
}
.cash_img {
  width: 120rpx;
  height: 120rpx;
}
.loactionIndex {
  width: 49rpx;
  height: 49rpx;
  background: linear-gradient(
    0deg,
    rgba(241, 17, 33, 1) 0%,
    rgba(255, 60, 95, 1) 100%
  );
  box-shadow: 0px 0px 16rpx 0px rgba(255, 60, 95, 0.48);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  line-height: 49rpx;
  text-align: center;
  font-size: 26rpx;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: rgba(255, 255, 255, 1);
  margin-right: 17rpx;
}
</style>
